package com.huawei.updatesdk.a.a.c.b.a;

import com.huawei.updatesdk.a.a.c.b.a.a.a;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

public class b {
    private static a a = a.MODE_SUPPORT_UNKNOWN;
    private static a b;

    public static a a() {
        b();
        if (a == a.MODE_SUPPORT_MTK_GEMINI) {
            b = d.b();
        } else {
            b = c.b();
        }
        return b;
    }

    public static boolean b() {
        if (a != a.MODE_SUPPORT_UNKNOWN) {
            return a == a.MODE_SUPPORT_HW_GEMINI || a == a.MODE_SUPPORT_MTK_GEMINI;
        } else {
            if (d()) {
                a = a.MODE_SUPPORT_MTK_GEMINI;
                return true;
            } else if (c()) {
                a = a.MODE_SUPPORT_HW_GEMINI;
                return true;
            } else {
                a = a.MODE_NOT_SUPPORT_GEMINI;
                return false;
            }
        }
    }

    public static boolean c() {
        boolean z = false;
        try {
            boolean booleanValue;
            Object c = c.c();
            if (c != null) {
                c = c.getClass().getMethod("isMultiSimEnabled", new Class[0]).invoke(c, new Object[0]);
                if (c instanceof Boolean) {
                    booleanValue = ((Boolean) c).booleanValue();
                    z = booleanValue;
                    com.huawei.updatesdk.a.a.b.a.a.a.a("mutiCardFactory", "isHwGeminiSupport1 " + z);
                    return z;
                }
            }
            booleanValue = false;
            z = booleanValue;
        } catch (NoSuchMethodException e) {
            com.huawei.updatesdk.a.a.b.a.a.a.d("mutiCardFactory", "MSimTelephonyManager.getDefault().isMultiSimEnabled()?" + e.toString());
        } catch (IllegalAccessException e2) {
            com.huawei.updatesdk.a.a.b.a.a.a.d("mutiCardFactory", "MSimTelephonyManager.getDefault().isMultiSimEnabled()" + e2.toString());
        } catch (InvocationTargetException e3) {
            com.huawei.updatesdk.a.a.b.a.a.a.d("mutiCardFactory", "MSimTelephonyManager.getDefault().isMultiSimEnabled()" + e3.toString());
        }
        com.huawei.updatesdk.a.a.b.a.a.a.a("mutiCardFactory", "isHwGeminiSupport1 " + z);
        return z;
    }

    private static boolean d() {
        boolean z = false;
        try {
            Field declaredField = Class.forName("com.mediatek.common.featureoption.FeatureOption").getDeclaredField("MTK_GEMINI_SUPPORT");
            declaredField.setAccessible(true);
            z = declaredField.getBoolean(null);
        } catch (ClassNotFoundException e) {
            com.huawei.updatesdk.a.a.b.a.a.a.b("mutiCardFactory", "FeatureOption.MTK_GEMINI_SUPPORT" + e.toString());
        } catch (NoSuchFieldException e2) {
            com.huawei.updatesdk.a.a.b.a.a.a.b("mutiCardFactory", "FeatureOption.MTK_GEMINI_SUPPORT" + e2.toString());
        } catch (IllegalAccessException e3) {
            com.huawei.updatesdk.a.a.b.a.a.a.b("mutiCardFactory", "FeatureOption.MTK_GEMINI_SUPPORT" + e3.toString());
        } catch (Exception e4) {
            com.huawei.updatesdk.a.a.b.a.a.a.b("mutiCardFactory", "FeatureOption.MTK_GEMINI_SUPPORT" + e4.toString());
        }
        com.huawei.updatesdk.a.a.b.a.a.a.a("mutiCardFactory", "isMtkGeminiSupport " + z);
        return z;
    }
}
